package com.hjy.controller;


import com.hjy.websocket.config.WsAnnotation;
import com.hjy.websocket.domain.StudentTest;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/WsTest")
@Api(tags = "WsTest")
public class WsTestController {


    //收到消息
    //类型测试
    @WsAnnotation(value = "testType")
    public void testType(StudentTest studentTest, List<StudentTest> studentTests, List<String> strings, Map<String, StudentTest> studentTestMap) {
        System.out.println("类型测试-一般类型");
        System.out.println(studentTest);
        System.out.println("类型测试-集合一般类型");
        System.out.println(studentTests);
        System.out.println("类型测试-集合string类型");
        System.out.println(strings);
        System.out.println("类型测试-集合map类型");
        System.out.println(studentTestMap);
    }


    //正常请求测试
    @WsAnnotation(value = "test")
    public String test(String param) throws InterruptedException {
        Thread.sleep(10000);
        if("1".equals(param)){
            return "请求成功";
        }else if("2".equals(param)) {
            RuntimeException err = new RuntimeException("请求错误");
            throw err;
        }else if("3".equals(param)){
            System.out.println(1 / 0);
        }
        return param;
    }

}

